package com.cndw.kungfu.model.pve;

import java.util.concurrent.ScheduledFuture;

import com.cndw.kungfu.domain.Player;
import com.cndw.kungfu.ext.TimeProcesser;
import com.cndw.kungfu.model.Context;

public class CityBattlePlayer implements Comparable<CityBattlePlayer> {

	private long playerId;

	private int dam;

	private int buff;

	private int dead;

	private ScheduledFuture<?> future;

	public long getPlayerId() {
		return playerId;
	}

	public void setPlayerId(long playerId) {
		this.playerId = playerId;
	}

	public int getDam() {
		return dam;
	}

	public void setDam(int dam) {
		this.dam = dam;
	}

	public void alterDam(int alter) {
		dam += alter;
	}

	public int getBuff() {
		return buff;
	}

	public void setBuff(int buff) {
		this.buff = buff;
	}

	public int getDead() {
		return dead;
	}

	public void setDead(int dead) {
		this.dead = dead;
	}

	public void killDeath(int endTime) {
		dead = endTime;
		future = Context.getTimerServer().scheduleSeconds(new Runnable() {
			@Override
			public void run() {
				dead = 0;
				Player player = Context.getPlayerServer().getByPlayerId(playerId);
				player.fullBloodMagic();
				if (player.getDataInfo().getPet() != null) {
					player.getDataInfo().getPet().fullHpMp();
				}
			}
		}, endTime - TimeProcesser.getUnixTime());
	}
	
	public boolean revive(){
		if (future != null) {
			future.cancel(false);
		}
		return true;
	}

	@Override
	public int compareTo(CityBattlePlayer o) {
		if (o.getDam() > getDam()) {
			return 1;
		} else {
			return -1;
		}
	}

}
